<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title><?php echo ($_page_title); ?></title>
    <link rel="stylesheet" href="/Public/Home/style/base.css" type="text/css">
    <link rel="stylesheet" href="/Public/Home/style/index.css" type="text/css">
    <link rel="stylesheet" href="/Public/Home/style/global.css" type="text/css">
    <link rel="stylesheet" href="/Public/Home/style/header.css" type="text/css">
    <link rel="stylesheet" href="/Public/Home/style/bottomnav.css" type="text/css" />
    <link rel="stylesheet" href="/Public/Home/style/footer.css" type="text/css" />
    <link rel="stylesheet" href="/Public/Home/style/goods.css" type="text/css">
    <link rel="stylesheet" href="/Public/Home/style/common.css" type="text/css">
    <script type="text/javascript" src="/Public/Home/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="/Public/Home/js/header.js"></script>
</head>
<body>
<!-- 顶部导航 start -->
<div class="topnav">
    <div class="topnav_bd w1210 bc">
        <div class="topnav_left">

        </div>
        <div class="topnav_right fr">
            <ul>
                <li id="loginInfo"></li>
                <li class="line">|</li>
                <li><a href="<?php echo U('My/order');?>">我的订单</a></li>
                <li class="line">|</li>
                <li>客户服务</li>

            </ul>
        </div>
    </div>
</div>
<!-- 顶部导航 end -->
<!-- -->
<?php if($_show_nav==1): ?>
   <div style="clear:both;"></div>
<!-- 头部 start -->
<div class="header w1210 bc mt15">
    <!-- 头部上半部分 start 包括 logo、搜索、用户中心和购物车结算 -->
    <div class="logo w1210">
        <h1 class="fl">
            <a href="<?php echo U('Index/index');?>"><img src="/Public/template/images/zx-logo.png" alt=""></a>
        </h1>
        <!-- 头部搜索 start -->
        <div class="search fl">
            <div class="search_form">
                <div class="form_left fl" style="background: #2cb2fd;opacity:0.5"></div>
                <form  name="search" method="get" class="fl" style="background: #2cb2fd;opacity:0.5;border: 1px">
                    <input id="key" name="key" type="text" class="txt"
                           value="<?php echo I('get.key','请输入商品关键字')?>"/>
                    <input onclick="location.href='<?php echo U('Search/key_search', '',FALSE); ?>/key/'+$('#key').val();" type="button" class="btn" value="搜索" />
                </form>
                <div class="form_right fl" style="background: #2cb2fd;opacity:0.5"></div>
            </div>

            <div style="clear:both;"></div>
        </div>
        <!-- 头部搜索 end -->

        <!-- 用户中心 start-->
        <div class="user fl">
            <dl>
                <dt>
                    <em></em>
                    <a href="">用户中心</a>
                    <b></b>
                </dt>
                <dd>
                    <div class="prompt">
                        您好，请<a href="<?php echo U('Member/login');?>">登录</a>
                    </div>
                    <div class="uclist mt10">
                        <ul class="list1 fl">
                            <li><a href="">用户信息></a></li>
                            <li><a href="">我的订单></a></li>
                            <li><a href="">收货地址></a></li>
                            <li><a href="">我的收藏></a></li>
                        </ul>

                        <ul class="fl">
                            <li><a href="">我的留言></a></li>
                            <li><a href="">我的红包></a></li>
                            <li><a href="">我的评论></a></li>
                            <li><a href="">资金管理></a></li>
                        </ul>

                    </div>
                    <div style="clear:both;"></div>
                    <div class="viewlist mt10">
                        <h3>最近浏览的商品：</h3>
                        <ul id="navhistory">
                        </ul>
                    </div>
                </dd>
            </dl>
        </div>
        <!-- 用户中心 end-->

        <!-- 购物车 start -->
        <div class="cart fl" >
            <dl>
                <dt>
                    <a  id="cart_list" href="<?php echo U('Cart/lst');?>">去购物车结算</a>
                </dt>
                <dd>
                    <div class="prompt" id="cart_div_list">
                        <img href="#" src ="/Public/Home/images/loading.gif"/>
                    </div>
                </dd>
            </dl>
        </div>
        <!-- 购物车 end -->
    </div>
    <!-- 头部上半部分 end -->

    <div style="clear:both;"></div>

    <!-- 导航条部分 start -->
    <div class="nav w1210 bc mt10" style="background: royalblue">
        <!--  商品分类部分 start-->
        <div class="category fl <?php if($_show_nav==0) echo 'cat1'?>" >
            <div class="cat_hd <?php if($_show_nav==0) echo 'off'?>" style="background: skyblue">  <!-- 注意，首页在此div上只需要添加cat_hd类，非首页，默认收缩分类时添加上off类，鼠标滑过时展开菜单则将off类换成on类 -->
                <h2 style="background: skyblue">全部商品分类<img style="margin-left: 80px" src="/Public/images/fenlei_icon.png"/></h2>
            </div>

            <div class="cat_bd <?php if($_show_nav==0) echo 'none'?>" style="opacity:0.9; background: whitesmoke";>
                <?php foreach($catData as $k => $v):?>
                <div class="cat <?php if($_show_nav==0) echo 'item1'?>">
                    <h3><a href="<?php echo U('Search/cat_search?cat_id='.$v['id'],'',FALSE)?>"><?php echo $v['cate_name']?></a> <b></b></h3>
                    <div class="cat_detail none">
                        <?php foreach($v['children'] as $k1 => $v1):?>
                        <dl <?php if($k1 ==0 ) echo 'class =dl_lst'?>>
                            <dt><a href="<?php echo U('Search/cat_search?cat_id='.$v1['id'],'',FALSE)?>"><?php echo $v1['cate_name']?></a></dt>
                            <dd>
                               <?php foreach($v1['chlderen'] as $k2 => $v2):?>
                            <a href="<?php echo U('Search/cat_search?cat_id='.$v2['id'],'',FALSE)?>"><?php echo $v2['cate_name']?></a>
                                <?php endforeach?>
                            </dd>
                        </dl>
                        <?php endforeach?>
                    </div>
                </div>
                <?php endforeach?>
            </div>
        </div>
        <!--  商品分类部分 end-->

        <div class="navitems fl" style="background: royalblue">
            <ul class="fl">
                <li class="current"><a style="background: royalblue" href="<?php echo U('Index/index');?>">首页</a></li>
                <li><a href="">电脑频道</a></li>
                <li><a href="">家用电器</a></li>
                <li><a href="">品牌大全</a></li>
                <li><a href="">团购</a></li>
                <li><a href="">积分商城</a></li>
                <li><a href="">夺宝奇兵</a></li>
            </ul>
            <div class="right_corner fl" style="background: royalblue"></div>
        </div>
    </div>
    <!-- 导航条部分 end -->
</div>
<!-- 头部 end-->
<div style="clear:both;"></div>
<script>
    <?php $config =C('IMAGE_CONFIG')?>
    var viewPath ='<?php echo $config['viewPath']?>';
    $.ajax({
        type: 'GET',
        url: "<?php echo U('Index/displayHistory?id='.$info['id'])?>",
        dataType: 'json',
        success:function (data) {
            var html = "";
            $(data).each(function (k,v) {
                html +='<li><a href="<?php echo U('Index/goods','',FALSE); ?>/id/'+v.id+'"><img src=" '+viewPath+v.mid_logo+'"/></a>' +
                '<a href="<?php echo U('Index/goods','',FALSE);?>/id/'+v.id +'">'+v.goods_name+'</a></li>';
            });
            $("#navhistory").html(html);
        }
    });
    $("#cart_list").mouseover(function () {
        $.ajax({
            type:'GET',
            url:"<?php echo U('Cart/ajaxCartList')?>",
            dataType:'json',
            success:function (data) {
                var a = 0;
                html ="<ul class='list-unstyled'>";
                $(data).each(function (k,v) {
                    html +='<li class="clearfix shopcart-goods-li" id="cart" value="'+v.goods_id+ '-'+v.goods_attr_id+'"><div style="float: left;" class="shopcart-goods-image">' +
                            '<img width="50" src="'+picView+v.mid_logo+'" /> ' +
                            '</div>';
                    html +='<div style="float: left;" class="shopcart-goods-name">' +
                            '<p>'+ v.goods_name+'</p>' +
                            '</div>';
                    html +='<div style="float: left;margin-left: 20px;" class="shopcart-goods-price">' +
                            '<div style="float: left";> ￥'+v.price+'</div>' +
                            '<div style="float: left";>' +
                            '<a info-data="' + v.goods_id + '-' + v.goods_attr_id + '" onclick="delCart( this )" href="javascript:void(0); ">删除</a>'+
                            '</div></div></li>';
                    a++

                });
                html +="</ul>";
                if(a>0){
                    $('#cart_div_list').html(html);
                }else{
                    $('#cart_div_list').css('display','block');
                }

            }
        });
    });
    //var count =0;
    $(function () {
        /*count = $('.list-unstyled').children.length;
         if(count > 0){
         $('#count').removeClass('hidden').html(count);
         }*/
        $.ajax({
            type:'GET',
            url:"<?php echo U('Cart/ajaxCartList')?>",
            dataType:'json',
            success:function (data) {
                var i = 0;
                $(data).each(function (k,v) {
                    i++;
                });
                if(i>0){
                    $('#count').removeClass('hidden').html(i);
                }
            }
        });
    });
    function delCart( a ){
        var info = $(a).attr('info-data');
        $.ajax({
            type:'GET',
            url:"<?php echo U('Cart/ajaxDelCart');?>",
            data:"id="+info,
            dataType:'json',
            success:function (data) {
                if(data.code==1){
                    $("li[value='+ info +']").remove();
                }
            }
        });
    }
    </script>
<?php endif;?>
<link rel="stylesheet" href="/Public/Home/style/cart.css" type="text/css">
<script type="text/javascript" src="/Public/Home/js/cart1.js"></script>

<!-- 页面头部 start -->
<div class="header w990 bc mt15">
    <div class="logo w990">
        <h2 class="fl"><a href="<?php echo U('Index/index');?>"><img src="/Public/template/images/zx-logo.png" alt="中兴商城"></a></h2>
        <div class="flow fr">
            <ul>
                <li class="cur">1.我的购物车</li>
                <li>2.填写核对订单信息</li>
                <li>3.成功提交订单</li>
            </ul>
        </div>
    </div>
</div>
<!-- 页面头部 end -->

<div style="clear:both;"></div>
<form action="<?php echo U('Cart/chengeNumber');?>" id="cart_form" method="post"/>
<!-- 主体部分 start -->
<div class="mycart w990 mt10 bc">
    <h2><span>我的购物车</span></h2>
    <table>
        <thead>
        <tr>
            <th class="col1">商品名称</th>
            <th class="col2">商品信息</th>
            <th class="col3">单价</th>
            <th class="col4">数量</th>
            <th class="col5">小计</th>
            <th class="col6">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php $tp = 0; foreach($data as $k => $v): ?>
        <tr>
            <td class="col1"><a href=""><?php echo showImage($v['mid_logo'])?></a>
                <strong>
                    <a href="<?php echo U('Index/goods?id=' .$v['goods_id'])?>"><?php echo ($v["goods_name"]); ?></a>
                </strong>
            </td>
            <td class="col2">
                <?php foreach($v['gaData'] as $k1 => $v1):?>
                <p><?php echo ($v1["attr_name"]); ?></p> <p><?php echo ($v1["attr_value"]); ?></p>
                <?php endforeach?>
            </td>
            <td class="col3">￥<span><?php echo ($v["price"]); ?></span></td>
            <td class="col4">
                <a href="javascript:;" class="reduce_num"></a>
                <input type="text" name="<?php echo ($v["goods_id"]); ?>-<?php echo ($v["goods_attr_id"]); ?>" value="<?php echo ($v["goods_number"]); ?>" class="amount"/>
                <a href="javascript:;" class="add_num"></a>
            </td>
            <td class="col5">￥<span><?php $xj = $v['price']*$v['goods_number'];$tp+=$xj;echo $xj;?></span></td>
            <td class="col6"><a href="">删除</a></td>
        </tr>
        <?php endforeach?>
        </tbody>
        <tfoot>
        <tr>
            <td colspan="6">购物金额总计： <strong>￥ <span id="total"><?php echo ($tp); ?></span></strong></td>
        </tr>
        </tfoot>
    </table>
    <div class="cart_btn w990 bc mt10">
        <a href="/" class="continue">继续购物</a>
        <a href="javascript:void (0)" name="submit"  onclick="document.getElementById('cart_form').submit();return false" class="checkout">结 算</a>
    </div>
</div>
</form>
<!-- 主体部分 end -->

<?php if($_show_nav==1): ?>
<div style="clear:both;"></div>
<!-- 底部导航 start -->
<div class="bottomnav w1210 bc mt10">
    <div class="bnav1">
        <h3><b></b> <em>购物指南</em></h3>
        <ul>
            <li><a href="">购物流程</a></li>
            <li><a href="">会员介绍</a></li>
            <li><a href="">团购/机票/充值/点卡</a></li>
            <li><a href="">常见问题</a></li>
            <li><a href="">大家电</a></li>
            <li><a href="">联系客服</a></li>
        </ul>
    </div>

    <div class="bnav2">
        <h3><b></b> <em>配送方式</em></h3>
        <ul>
            <li><a href="">上门自提</a></li>
            <li><a href="">快速运输</a></li>
            <li><a href="">特快专递（EMS）</a></li>
            <li><a href="">如何送礼</a></li>
            <li><a href="">海外购物</a></li>
        </ul>
    </div>


    <div class="bnav3">
        <h3><b></b> <em>支付方式</em></h3>
        <ul>
            <li><a href="">货到付款</a></li>
            <li><a href="">在线支付</a></li>
            <li><a href="">分期付款</a></li>
            <li><a href="">邮局汇款</a></li>
            <li><a href="">公司转账</a></li>
        </ul>
    </div>

    <div class="bnav4">
        <h3><b></b> <em>售后服务</em></h3>
        <ul>
            <li><a href="">退换货政策</a></li>
            <li><a href="">退换货流程</a></li>
            <li><a href="">价格保护</a></li>
            <li><a href="">退款说明</a></li>
            <li><a href="">返修/退换货</a></li>
            <li><a href="">退款申请</a></li>
        </ul>
    </div>

    <div class="bnav5">
        <h3><b></b> <em>特色服务</em></h3>
        <ul>
            <li><a href="">夺宝岛</a></li>
            <li><a href="">DIY装机</a></li>
            <li><a href="">延保服务</a></li>
            <li><a href="">家电下乡</a></li>
            <li><a href="">京东礼品卡</a></li>
            <li><a href="">能效补贴</a></li>
        </ul>
    </div>
</div>


<?php endif;?>

<!-- 底部版权 start -->
<div style="clear:both;"></div>
<div class="footer w1210 bc mt10">
    <p class="links">
        <a href="">关于我们</a> |
        <a href="">联系我们</a> |
        <a href="">人才招聘</a> |
        <a href="">商家入驻</a> |
        <a href="">千寻网</a> |
        <a href="">奢侈品网</a> |
        <a href="">广告服务</a> |
        <a href="">移动终端</a> |
        <a href="">友情链接</a> |
        <a href="">销售联盟</a> |
        <a href="">京西论坛</a>
    </p>
    <p class="copyright">
        © 2005-2013 京东网上商城 版权所有，并保留所有权利。  ICP备案证书号:京ICP证070359号
    </p>
    <p class="auth">
        <a href=""><img src="/Public/Home/images/xin.png" alt="" /></a>
        <a href=""><img src="/Public/Home/images/kexin.jpg" alt="" /></a>
        <a href=""><img src="/Public/Home/images/police.jpg" alt="" /></a>
        <a href=""><img src="/Public/Home/images/beian.gif" alt="" /></a>
    </p>
</div>
<!-- 底部版权 end -->
</body>
</html>
<script>
    $.ajax({
        type:'GET',
        url: "<?php echo U('Member/ajaxChkLogin');?>",
        dataType:'json',
        success:function (data) {
            if(data.login ==1){
                var li ='您好,'+ data.username + '[<a href="<?php echo U('Member/logout');?>">退出</a>]';
                $('#loginInfo').html(li);
            }else{
                var li ='您好,欢迎来中兴![<a href="<?php echo U('Member/login');?>">登录</a>] [<a href="<?php echo U('Member/regist') ?>">免费注册</a>]';
                $('#loginInfo').html(li);
            }
        }
    });
</script>